﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Data;

namespace ShoppeWCFService
{
    [ServiceContract]
    public interface IShoppeService
    {
        /// <summary>
        /// Returns the products, whith choosen category you want to see
        /// </summary>
        /// <param name="targetCategory">The name of the category</param>
        /// <returns>All products with target category</returns>
        [OperationContract]
        DataSet getTargetCategory(String targetCategory);

        /// <summary>
        /// Get the product of target ID
        /// </summary>
        /// <param name="targetId">Choosen Id</param>
        /// <returns>The product in form of a DataSet</returns>
        [OperationContract]
        DataSet getTargetProduct(int targetId);

        /// <summary>
        /// Returns a collection of strings with all the categorys in the databas
        /// Main use is to have easy access, when filling menus and inputs in the pages
        /// </summary>
        /// <returns>Collection of the names of all categorys in database</returns>
        [OperationContract]
        List<String> getAllCategorys();

        /// <summary>
        /// Returns a DataSet contaning all categorys and there corresponding ID 
        /// </summary>
        /// <returns>All categorys in database</returns>
        [OperationContract]
        DataSet getCategorys();

        /// <summary>
        /// Returns a DataSet contaning all imageURL's and there corresponding ID 
        /// </summary>
        /// <returns>All images in database</returns>
        [OperationContract]
        DataSet getAllImages();

        /// <summary>
        /// Insert a new product in the database
        /// </summary>
        /// <param name="name">Product name</param>
        /// <param name="imageURL">Target imageURL ID</param>
        /// <param name="description">Text describing how the product works, behavie, looks etc.</param>
        /// <param name="stockStatus">How many items of the product we initially have in stock</param>
        /// <param name="category">What type of a product</param>
        /// <param name="price">The cost of the product</param>
        [OperationContract]
        void addNewProduct(String name, String imageURL, String description, int stockStatus, String category, int price);

        /// <summary>
        /// Returns the products where the name contains the parameter
        /// </summary>
        /// <param name="sWord">Part of a product name</param>
        /// <returns>All products in a DataSet that contains searchword</returns>
        [OperationContract]
        DataSet search(String sWord);

        /// <summary>
        /// Get all products in database
        /// </summary>
        /// <returns>All products in a DataSet</returns>
        [OperationContract]
        DataSet GetProducts();

        /// <summary>
        /// Update the OrderProduct table, and update the amount of target product
        /// </summary>
        [OperationContract]
        void UpdateStockStatus(int newAmount, int productId);

        /// <summary>
        /// Gets a smaller version of the productTable in database
        /// </summary>
        /// <returns>DataSet: productId, name, productDescription, stockStatus, price</returns>
        [OperationContract]
        DataSet GetProductsSimple();

        /// <summary>
        /// Inserts a new product to target order and the amount of the item
        /// </summary>
        /// <param name="orderId">Target order</param>
        /// <param name="productId">Target product</param>
        /// <param name="amount">How many items of target product</param>
        [OperationContract]
        void AddProductToOrder(int orderId, int productId, int amount);

        /// <summary>
        /// Get target order
        /// </summary>
        /// <param name="orderId">Target order (primary key)</param>
        /// <returns>DataSet that contains target order</returns>
        [OperationContract]
        DataSet GetOrder(int orderId);

        /// <summary>
        /// Get All orders
        /// </summary>
        /// <returns>DataSet that contains all orders</returns>
        [OperationContract]
        DataSet GetOrders();

        /// <summary>
        /// Insert new order, owned by target user
        /// </summary>
        /// <param name="userId">userID from ASP.Net local database</param>
        /// <param name="date">The date and time the order is createad</param>
        [OperationContract]
        void AddOrder(string userId, DateTime date);

        /// <summary>
        /// Get all orders from target user, sorted: last order first
        /// </summary>
        /// <param name="userId">userID from ASP.Net local database</param>
        /// <returns></returns>
        [OperationContract]
        DataSet GetOrdersByUser(string userId);

        /// <summary>
        /// Get all products in database that contains prefixText. Main use is to get easy access to fill
        /// menus, inputs etc. 
        /// </summary>
        /// <example>
        /// AJAX: AutoComplete result in product search
        /// </example>
        /// <param name="prefixText">Part of product name</param>
        /// <returns>Array of product names that contains prefixText</returns>
        [OperationContract]
        string[] GetCompletionList(string prefixText);
    }
}
